package com.wu.controller;

import com.wu.feign.MenuFeign;
import com.wu.pojo.Menu;
import com.wu.vo.MenuVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Controller
@RequestMapping("/client")
public class ClientController {
    @Autowired
    private MenuFeign menuFeign;
//这个是我们测试用的，laYUI会默认给我们传递index和limit所以我们不需要用这个了，改为下面的
//    @GetMapping("/findall/{index}/{limit}")
//    public List<Menu> findAll(@PathVariable("index") int index, @PathVariable("limit") int limit){
//        return menuFeign.findAll(index, limit);
//    }
    @GetMapping("/findall")
    @ResponseBody//返回数据，不返回视图
    public MenuVo findAll(@RequestParam("page") int page, @RequestParam("limit") int limit){
        int index=(page-1)*limit;
        return menuFeign.findAll(index, limit);
    }


    @GetMapping("/redirect/{location}")
    public String redirect(@PathVariable("location") String location){
        return location;
    }


}
